VERSION 5.00 Begin VB.Form frmWinView AutoRedraw = -1 'True BorderStyle = 3 'Fixed Dialog Caption = "Windows Information Viewer - By Chong Long Choo" ClientHeight = 8205 ClientLeft = 45 ClientTop = 330 ClientWidth = 6780 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 547 ScaleMode = 3 'Pixel ScaleWidth = 452 StartUpPosition = 2 'CenterScreen Begin VB.ListBox lstOwnedWin ForeColor = &H00FF0000& Height = 450 Left = 120 TabIndex = 13 TabStop = 0 'False Top = 2880 Width = 6555 End Begin VB.ListBox lstChildWin ForeColor = &H00FF0000& Height = 645 Left = 120 TabIndex = 11 TabStop = 0 'False Top = 1800 Width = 6555 End Begin VB.CommandButton cmdRefresh Caption = "Refresh" Height = 375 Left = 120 TabIndex = 9 Top = 7680 Width = 1935 End Begin VB.ListBox lstTopLevelWin ForeColor = &H00FF0000& Height = 1035 Left = 120 TabIndex = 3 TabStop = 0 'False Top = 360 Width = 6555 End Begin VB.ListBox ListInfo ForeColor = &H00FF0000& Height = 840 Index = 0 Left = 4560 TabIndex = 2 TabStop = 0 'False Top = 3720 Width = 2175 End Begin VB.TextBox Text1 Appearance = 0 'Flat ForeColor = &H00FF0000& Height = 285 Index = 0 Left = 1920 Locked = -1 'True TabIndex = 1 TabStop = 0 'False Top = 3480 Visible = 0 'False Width = 1815 End Begin VB.CommandButton cmdTrack Caption = "Start Tracking" Height = 375 Left = 2160 TabIndex = 0 Top = 7680 Width = 1935 End Begin VB.Timer Timer1 Enabled = 0 'False Interval = 50 Left = 2400 Top = 4080 End Begin VB.Label Label4 Height = 255 Left = 120 TabIndex = 12 Top = 2520 Width = 5055 WordWrap = -1 'True End Begin VB.Label Label3 Height = 255 Left = 120 TabIndex = 10 Top = 1440 Width = 5055 WordWrap = -1 'True End Begin VB.Label Label5 Caption = "CLASS" Height = 255 Index = 2 Left = 3600 TabIndex = 8 Top = 120 Width = 1215 End Begin VB.Label Label5 Caption = "BASE" Height = 255 Index = 1 Left = 1440 TabIndex = 7 Top = 120 Width = 1215 End Begin VB.Label Label5 Caption = "HWND" Height = 255 Index = 0 Left = 120 TabIndex = 6 Top = 120 Width = 1215 End Begin VB.Label Label2 AutoSize = -1 'True Caption = "Class Info:" Height = 195 Index = 0 Left = 4560 TabIndex = 5 Top = 3480 Visible = 0 'False Width = 735 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "&Hwnd:" Height = 195 Index = 0 Left = 240 TabIndex = 4 Top = 3480 Visible = 0 'False Width = 465 End Attribute VB_Name = "frmWinView" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit ' Name: Windows Information Viewer ' Author: Chong Long Choo ' Date: 06 September 1999 Private Type POINTAPI x As Long y As Long End Type Private objWinView As clsWinView Attribute objWinView.VB_VarHelpID = -1 Private Declare Function SendMessageLongByRef Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, lParam As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE Private Const BITSPIXEL As Long = 12 Private Const HORZRES As Long = 8 Private Const VERTRES As Long = 10 Private Const LB_SETTABSTOPS = &H192 ' Load all label, text box and list box Private Sub LoadLabelText() Dim ArrayCaption1 As Variant Dim ArrayCaption2 As Variant Dim i As Byte ArrayCaption1 = Array("Base:", "Class:", _ "Position:", "Size (Horizontal):", "Size (Vertical):", _ "Class Extra:", "Word Extra:", "Control Name:", _ "Parent Window:", "Window Name:") ArrayCaption2 = Array("Condition:", "Style:", "Extra Style:") Label2(0).Visible = True ListInfo(0).Visible = True For i = 1 To 3 Load Label2(i) Load ListInfo(i) ListInfo(i).Move 304, ListInfo(i - 1).Top + 80 Label2(i).Caption = ArrayCaption2(i - 1) Label2(i).Move 304, Label2(i - 1).Top + 80 Label2(i).Visible = True ListInfo(i).Visible = True Next Label1(0).Visible = True Text1(0).Visible = True For i = 1 To 10 Load Label1(i) Load Text1(i) Label1(i).Caption = ArrayCaption1(i - 1) Label1(i).Move 16, Label1(i - 1).Top + 24 Text1(i).Move 128, Text1(i - 1).Top + 24 Text1(i).Visible = True Label1(i).Visible = True Next End Sub ' Refresh the list of top level windows Private Sub cmdRefresh_Click() LoadTopLevelWindows End Sub 'List top level windows Private Sub LoadTopLevelWindows() lstTopLevelWin.Clear objWinView.ListTopLevelWindow lstTopLevelWin.ListIndex = 0 End Sub ' Detect the information of the window which under ' the mouse Private Sub cmdTrack_Click() Static bTracking As Boolean If Not bTracking Then objWinView.SetPointMode hwnd WinInfo objWinView.GetWindowDesc(cmdTrack.hwnd) bTracking = True cmdTrack.Caption = "Stop Tracking" Timer1.Enabled = True Else objWinView.ResetPointMode hwnd cmdTrack.Caption = "Start Tracking" bTracking = False Timer1.Enabled = False End If End Sub Private Sub Form_Activate() ' set the form to top most Call SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) End Sub 'Detect screen resolution 'If the current horizontal resolution and the current 'vertical resolution do not greater than 800 and 600, 'the sample will be terminated automatically. Private Sub DetectScreenResolution() Dim HRes As Long Dim VRes As Long HRes = GetDeviceCaps(hdc, HORZRES) VRes = GetDeviceCaps(hdc, VERTRES) If HRes < 800 And VRes < 600 Then MsgBox "This sample is best viewed in 800 by 600 pixels. " & _ "Change your screen resolution to 800 by 600 pixels. This " & _ "sample will be terminated.", vbInformation, "ViewWinInfo" End End If End Sub Private Sub Form_Load() DetectScreenResolution Set objWinView = New clsWinView ' set the form to top most Call SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) LoadLabelText SetTabsTops lstChildWin.hwnd SetTabsTops lstOwnedWin.hwnd SetTabsTops lstTopLevelWin.hwnd LoadTopLevelWindows End Sub Private Sub Form_Unload(Cancel As Integer) Call SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS) Set objWinView = Nothing End Sub ' Get the information of the specific window Private Sub WinInfo(Optional strTmp As String, Optional lngHwnd As Long) Static TmpHwnd As Long Dim tmpobjWinPos As clsWinPosition Dim objTmpWinSize As clsWinSize Dim strPos As String Dim objTmpClassInfo As clsClassInfo Dim objTmpWinStyle As clsWInStyle Dim objTmpWinExStyle As clsWinExStyle If TmpHwnd = objWinView.GetHwndFromWord(strTmp) Then Exit Sub TmpHwnd = objWinView.GetHwndFromWord(strTmp) Set objTmpWinStyle = New clsWInStyle Set objTmpClassInfo = New clsClassInfo Set tmpobjWinPos = New clsWinPosition Set objTmpWinSize = New clsWinSize Set objTmpWinExStyle = New clsWinExStyle ListInfo(0).Clear ListInfo(2).Clear ListInfo(1).Clear ListInfo(3).Clear With objWinView Text1(0) = "&H" & TmpHwnd Text1(1) = .GetBaseNameFromWord(strTmp) Text1(2) = .GetClassNameFromWord(strTmp) .GetPosition TmpHwnd, tmpobjWinPos .GetSize TmpHwnd, objTmpWinSize .GetClassInfo TmpHwnd, objTmpClassInfo Text1(8) = .GetCtlName(TmpHwnd) Text1(9) = .GetParentWindow(TmpHwnd) Text1(10) = .GetWindowTitle(TmpHwnd) .GetWinStyle TmpHwnd, objTmpWinStyle .GetWinExStyle TmpHwnd, objTmpWinExStyle End With With objTmpWinStyle If .WS_BORDER Then ListInfo(2).AddItem "WS_BORDER" If .WS_CAPTION Then ListInfo(2).AddItem "WS_CAPTION" If .WS_CHILD Then ListInfo(2).AddItem "WS_CHILD" If .WS_CLIPCHILDREN Then ListInfo(2).AddItem "WS_CLIPCHILDREN" If .WS_CLIPSIBLINGS Then ListInfo(2).AddItem "WS_CLIPSIBLINGS" If .WS_DISABLED Then ListInfo(2).AddItem "WS_DISABLED" If .WS_DLGFRAME Then ListInfo(2).AddItem "WS_DLGFRAME" If .WS_GROUP Then ListInfo(2).AddItem "WS_GROUP" If .WS_HSCROLL Then ListInfo(2).AddItem "WS_HSCROLL" If .WS_MAXIMIZE Then ListInfo(2).AddItem "WS_MAXIMIZE" If .WS_MAXIMIZEBOX Then ListInfo(2).AddItem "WS_MAXIMIZEBOX" If .WS_POPUP Then ListInfo(2).AddItem "WS_POPUP" If .WS_SYSMENU Then ListInfo(2).AddItem "WS_SYSMENU" If .WS_TABSTOP Then ListInfo(2).AddItem "WS_TABSTOP" If .WS_THICKFRAME Then ListInfo(2).AddItem "WS_THICKFRAME" If .WS_VISIBLE Then ListInfo(2).AddItem "WS_VISIBLE" If .WS_VSCROLL Then ListInfo(2).AddItem "WS_VSCROLL" End With With objTmpWinSize Text1(4) = .Horiz_Pixels Text1(5) = .Vert_Pixels End With With objTmpClassInfo Text1(6) = .Class_Extra Text1(7) = .Word_Extra If .CS_BYTEALIGNCLIENT Then ListInfo(0).AddItem "CS_BYTEALIGNCLIENT" If .CS_BYTEALIGNWINDOW Then ListInfo(0).AddItem "CS_BYTEALIGNWINDOW" If .CS_CLASSDC Then ListInfo(0).AddItem "CS_CLASSDC" If .CS_DBLCLKS Then ListInfo(0).AddItem "CS_DBLCLKS" If .CS_HREDRAW Then ListInfo(0).AddItem "CS_HREDRAW" If .CS_VREDRAW Then ListInfo(0).AddItem "CS_VREDRAW" If .CS_NOCLOSE Then ListInfo(0).AddItem "CS_NOCLOSE" If .CS_OWNDC Then ListInfo(0).AddItem "CS_OWNDC" If .CS_PARENTDC Then ListInfo(0).AddItem "CS_PARENTDC" If .CS_PUBLICCLASS Then ListInfo(0).AddItem "CS_PUBLICCLASS" If .CS_SAVEBITS Then ListInfo(0).AddItem "CS_SAVEBITS" End With With objTmpWinExStyle If .WS_EX_ACCEPTFILES Then ListInfo(3).AddItem "WS_EX_ACCEPTFILES" If .WS_EX_APPWINDOW Then ListInfo(3).AddItem "WS_EX_APPWINDOW" If .WS_EX_CLIENTEDGE Then ListInfo(3).AddItem "WS_EX_CLIENTEDGE" If .WS_EX_CONTEXTHELP Then ListInfo(3).AddItem "WS_EX_CONTEXTHELP" If .WS_EX_CONTROLPARENT Then ListInfo(3).AddItem "WS_EX_CONTROLPARENT" If .WS_EX_DLGMODALFRAME Then ListInfo(3).AddItem "WS_EX_DLGMODALFRAME" If .WS_EX_LAYERED Then ListInfo(3).AddItem "WS_EX_LAYERED" If .WS_EX_LAYOUTRTL Then ListInfo(3).AddItem "WS_EX_LAYOUTRTL" If .WS_EX_LEFT Then ListInfo(3).AddItem "WS_EX_LEFT" If .WS_EX_LEFTSCROLLBAR Then ListInfo(3).AddItem "WS_EX_LEFTSCROLLBAR" If .WS_EX_LTRREADING Then ListInfo(3).AddItem "WS_EX_LTRREADING" If .WS_EX_MDICHILD Then ListInfo(3).AddItem "WS_EX_MDICHILD" If .WS_EX_NOACTIVATE Then ListInfo(3).AddItem "WS_EX_NOACTIVATE" If .WS_EX_NOINHERITLAYOUT Then ListInfo(3).AddItem "WS_EX_NOINHERITLAYOUT" If .WS_EX_NOPARENTNOTIFY Then ListInfo(3).AddItem "WS_EX_NOPARENTNOTIFY" If .WS_EX_OVERLAPPEDWINDOW Then ListInfo(3).AddItem "WS_EX_OVERLAPPEDWINDOW" If .WS_EX_PALETTEWINDOW Then ListInfo(3).AddItem "WS_EX_PALETTEWINDOW" If .WS_EX_RIGHT Then ListInfo(3).AddItem "WS_EX_RIGHT" If .WS_EX_RIGHTSCROLLBAR Then ListInfo(3).AddItem "WS_EX_RIGHTSCROLLBAR" If .WS_EX_RTLREADING Then ListInfo(3).AddItem "WS_EX_RTLREADING" If .WS_EX_STATICEDGE Then ListInfo(3).AddItem "WS_EX_STATICEDGE" If .WS_EX_TOOLWINDOW Then ListInfo(3).AddItem "WS_EX_TOOLWINDOW" If .WS_EX_TOPMOST Then ListInfo(3).AddItem "WS_EX_TOPMOST" If .WS_EX_TRANSPARENT Then ListInfo(3).AddItem "WS_EX_TRANSPARENT" If .WS_EX_WINDOWEDGE Then ListInfo(3).AddItem "WS_EX_WINDOWEDGE" End With With tmpobjWinPos strPos = "(" & .Left & "," & .Top & ") - (" & _ .Right & "," & .Bottom & ")" Text1(3) = strPos If .Is_Enabled Then ListInfo(1).AddItem "Is_Enabled" If .Is_Iconic Then ListInfo(1).AddItem "Is_Icon" If .Is_Visible Then ListInfo(1).AddItem "Is_Visible" If .Is_Zoomed Then ListInfo(1).AddItem "Is_Zoom" End With Set objTmpWinStyle = Nothing Set objTmpClassInfo = Nothing Set tmpobjWinPos = Nothing Set objTmpWinSize = Nothing End Sub Sub SetTabsTops(ByVal LBHwnd As Long) Dim tabsets&(2) tabsets(0) = 45 tabsets(1) = 110 Call SendMessageLongByRef(LBHwnd, LB_SETTABSTOPS, 2, tabsets(0)) End Sub Private Sub lstChildWin_Click() WinInfo lstChildWin.Text End Sub Private Sub lstOwnedWin_Click() WinInfo lstOwnedWin.Text End Sub Private Sub lstTopLevelWin_Click() On Local Error Resume Next WinInfo lstTopLevelWin.Text 'List child windows of the selected window Dim strWindowDesc As String strWindowDesc = lstTopLevelWin.Text lstChildWin.Clear Call objWinView.GetChild(0&, strWindowDesc) Label3 = "Children of: " + "&" + strWindowDesc lstChildWin.ListIndex = 0 'List owned windows of the selected window strWindowDesc = lstTopLevelWin.Text objWinView.GetOwnedWindow 0&, strWindowDesc lstOwnedWin.Clear lstOwnedWin.ListIndex = 0 Label4.Caption = "Owned windows of: " + "&" + strWindowDesc End Sub Private Sub Timer1_Timer() Dim CurPos As POINTAPI Call GetCursorPos(CurPos) WinInfo objWinView.GetWindowFromPoint(hwnd, CurPos.x, CurPos.y) End Sub